var a = 0;
var text;
var selects;
var buynum = 0;
var itemlist = Array(Array(3015002, 700), Array(3015051, 500), Array(3010853, 600), Array(3010832, 600), Array(3010788, 450), Array(3010658, 450), Array(3010621, 450), Array(3010842, 260), Array(3010843, 260), Array(3010876, 260), Array(3010936, 260), Array(3012025, 260), Array(3010696, 230), Array(3010718, 200), Array(3010519, 200), Array(3010520, 200), Array(3010070, 200), Array(3012011, 100), Array(3012019, 100), Array(3012010, 100), Array(3012001, 100), Array(3012025, 100), Array(3010736, 100), Array(3012024, 100), Array(3012020, 100), Array(3010528, 50), Array(3010877, 20), Array(3010813, 20), Array(3010660, 20), Array(3010661, 20), Array(3010715, 20), Array(3010716, 20), Array(3010717, 20), Array(3010527, 20));

function start() {
    a = -1;
    action(1, 0, 0)
}

function action(f, e, d) {
    if (f == -1) {
        cm.dispose()
    } else {
        if (f == 1) {
            a++
        } else {
            a--
        }
        if (a == -1) {
            cm.dispose()
        } else {
            if (a == 0) {
                text = "#h0#,您可以在这里兑换#e#b稀有椅子#n#k,我们只出售部分椅子\r\n#r#L0#点我进入到试用模式#l\r\n\r\n#b";
                for (var b = 1; b <= itemlist.length; b++) {
                    text += "#L" + (b) + "##i" + itemlist[b - 1] + ":##t" + itemlist[b - 1] + "# - #r" + itemlist[b - 1][1] + "#b点卷  \r\n";
                    if (b != 0 && (b + 1) % 5 == 0) {
                        text += "\r\n"
                    }
                }
                cm.askMenu(text)
            } else {
                if (a == 1) {
                    if (d == 0) {
                        cm.dispose();
                        cm.openNpc(9000069, 202);
                        return
                    } else {
                        selects = (d - 1)
                    }
                    buynum = 1;
                    cm.askYesNo("你想购买" + buynum + "个#r#i" + itemlist[selects][0] + "##k？\r\n你将使用掉" + (buynum * itemlist[selects][1]) + "点卷。")
                } else {
                    if (a == 2) {
                        var c = buynum * itemlist[selects][1];
                        if (cm.getPlayer().getCSPoints(1) < c) {
                            cm.dispose();
                            cm.sendOk("抱歉，你没足够的点卷！")
                        } else {
                            cm.gainItem(itemlist[selects][0], buynum);
                            cm.sendOk("购买成功了！");
                            cm.dispose()
                        }
                    }
                }
            }
        }
    }
}
var status = -1;